package com.storage.mongo;

import java.net.UnknownHostException;
import java.util.Date;

import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;
import com.mongodb.MongoException;

public class Login {
	
	Morphia morp;
	Mongo m; 
	DB db; 
	DBCollection topicColl; 
	Datastore ds;
	Login() throws UnknownHostException, MongoException
	{
		morp = new Morphia();
		m = new Mongo( "localhost" , 27017 );
		//drop db
		//m.dropDatabase("mydb");
		db = m.getDB("mydb");
		morp.map(ETopic.class).map(EComments.class);
		ds = morp.createDatastore("mydb");
	}
	
	
	public String createLogin(String name,String password) throws UnknownHostException, MongoException 
	{
		ELogin login = new ELogin();
		login.setName(name);
		login.setPasswordfield(password);
		ds.save(login);
		System.out.println("Login created successfully");
		
		
		return name+"+"+password;
	}

}
